<template>
  <div>
    <!-- 头部 -->
    <van-nav-bar title="钻石商城" fixed>
      <template #left>
        <img src="../../assets/images/形状38.png" alt="" @click="prev()" />
      </template>
    </van-nav-bar>
    <!-- 钻石明细 -->
    <div class="my">
      <div class="top">
        <div class="left">
          <h3>我的钻石</h3>
          <div>
            <img src="../../assets/images/钻石.png" alt="" />
            <span>0</span>
          </div>
        </div>
        <div class="right">
          <span>兑换记录</span>
        </div>
      </div>
    </div>
    <!-- 列表 -->
    <div class="list">
      <ul>
        <li class="navleft" v-for="(item, index) in diamondList" :key="index">
          <img :src="item.img" alt="" />
          <span>{{ item.des }}</span>
          <div>
            <div class="pleft">
              <p>已售 {{ item.sell }}</p>
            </div>
            <div class="spanright">
              <p class="img"></p>
              <p>{{ item.Diamond }}</p>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { NavBar } from "vant";
import { computed, onMounted } from "vue";
import { useStore } from "vuex";
export default {
  components: {
    vanNavBar: NavBar,
  },
  methods: {
    prev() {
      this.$router.go(-1);
    },
  },
  setup() {
    const store = useStore();
    const diamondList = computed(() => {
      return store.state.diamond.diamondList;
    });
    onMounted(() => {
      store.dispatch("getdiamondAsync");
    });
    return { diamondList };
  },
};
</script>

<style lang="less" scoped>
.my {
  padding: 15px 15px 5px;
  .top {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    vertical-align: top;
    .left {
      display: flex;
      font-size: 14px;
      width: 200px;
      div {
        margin-top: 4px;
        img {
          width: 20px;
          height: 20px;
          margin-left: 15px;
        }
        span {
          font-weight: 900;
          vertical-align: top;
          margin-left: 5px;
        }
      }
    }
    .right {
      display: flex;
      font-size: 14px;
      color: #000;
    }
  }
}
.list {
  padding: 15px;
  display: flex;
  img {
    height: 165px;
    width: 165px;
  }
  ul {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .navleft {
    background: url("../../assets/images/矩形3拷贝.png") no-repeat;
    height: 246px;
    width: 165px;
    display: flex;
    position: relative;
    margin-bottom: 10px;
    span {
      position: absolute;
      top: 182px;
      left: 12px;
      font-size: 12px;
      font-weight: 700;
    }
    .pleft {
      position: absolute;
      bottom: 5px;
      left: 12px;
      color: #ccc;
      font-size: 14px;
    }
    .spanright {
      position: absolute;
      bottom: 0;
      right: 12px;
      font-size: 14px;
      display: flex;
      font-weight: 700;
      .img {
        background: url("../../assets/images/组2(1).png") no-repeat;
        width: 23px;
        height: 20px;
      }
    }
  }
  .navleft:nth-child(odd) {
    margin-right: 15px;
  }
}
</style>
